
keep if  ( yearsince>=-1 & yearsince<=3 ) 

capture frame drop results
frame create results str10 outcomevar evicted notevicted time

foreach var of varlist app shelt {

reg `var' evictionorder qdum2-qdum5 evictXq2-evictXq5 i.yearsince i.courtq 
		
*Calculate omitted group baseline mean
sum `var' if evictionorder==0 & yearsince==-1  & e(sample)==1
local basemean=r(mean)
		
* adding period 1 (first) estimates
local rel_q=1-5
local qplot=`rel_q' 
local noevictplot= `basemean'
local evictplot=`basemean'+ _b[evictionorder] 	
frame post results ("`var'")  (`evictplot') (`noevictplot') (`qplot')
	
foreach num of numlist 2(1)5 {
			local rel_q=`num'-5
			local qplot=`rel_q' 
			local noevictplot= `basemean'+_b[qdum`num']
			local evictplot=`basemean'+ _b[evictionorder]+_b[qdum`num']+_b[evictXq`num'] 
			frame post results ("`var'")  (`evictplot') (`noevictplot') (`qplot')
}
		
}
frame change results

gen outcome="Any Homeless System Use" if outcomevar=="app" 
gen outcome="Emergency Shelter Use" if outcomevar=="shelt" 

save  ${Inputs}\NY_homelessness_eventstudy, replace
